<!-- 分页组件 -->
{% if pagination.pages > 1 %}
<nav aria-label="分页导航" class="mt-4">
    <div class="row align-items-center">
        <div class="col-sm-6">
            <div class="pagination-info text-muted">
                显示第 {{ pagination.per_page * (pagination.page - 1) + 1 }} -
                {{ pagination.per_page * (pagination.page - 1) + pagination.items|length }} 条，
                共 {{ pagination.total }} 条记录
            </div>
        </div>
        <div class="col-sm-6">
            <ul class="pagination justify-content-end mb-0">
                <!-- 首页 -->
                {% if pagination.has_prev %}
                    <li class="page-item">
                        <a class="page-link" href="{{ url_for(request.endpoint, page=1, **request.args.to_dict(flat=False)|reject_pagination) }}">
                            <i class="bi bi-chevron-double-left"></i>
                        </a>
                    </li>
                {% else %}
                    <li class="page-item disabled">
                        <span class="page-link"><i class="bi bi-chevron-double-left"></i></span>
                    </li>
                {% endif %}

                <!-- 上一页 -->
                {% if pagination.has_prev %}
                    <li class="page-item">
                        <a class="page-link" href="{{ url_for(request.endpoint, page=pagination.prev_num, **request.args.to_dict(flat=False)|reject_pagination) }}">
                            <i class="bi bi-chevron-left"></i>
                        </a>
                    </li>
                {% else %}
                    <li class="page-item disabled">
                        <span class="page-link"><i class="bi bi-chevron-left"></i></span>
                    </li>
                {% endif %}

                <!-- 页码 -->
                {% for page_num in pagination.iter_pages() %}
                    {% if page_num %}
                        {% if page_num != pagination.page %}
                            <li class="page-item">
                                <a class="page-link" href="{{ url_for(request.endpoint, page=page_num, **request.args.to_dict(flat=False)|reject_pagination) }}">{{ page_num }}</a>
                            </li>
                        {% else %}
                            <li class="page-item active">
                                <span class="page-link">{{ page_num }}</span>
                            </li>
                        {% endif %}
                    {% else %}
                        <li class="page-item disabled">
                            <span class="page-link">…</span>
                        </li>
                    {% endif %}
                {% endfor %}

                <!-- 下一页 -->
                {% if pagination.has_next %}
                    <li class="page-item">
                        <a class="page-link" href="{{ url_for(request.endpoint, page=pagination.next_num, **request.args.to_dict(flat=False)|reject_pagination) }}">
                            <i class="bi bi-chevron-right"></i>
                        </a>
                    </li>
                {% else %}
                    <li class="page-item disabled">
                        <span class="page-link"><i class="bi bi-chevron-right"></i></span>
                    </li>
                {% endif %}

                <!-- 末页 -->
                {% if pagination.has_next %}
                    <li class="page-item">
                        <a class="page-link" href="{{ url_for(request.endpoint, page=pagination.pages, **request.args.to_dict(flat=False)|reject_pagination) }}">
                            <i class="bi bi-chevron-double-right"></i>
                        </a>
                    </li>
                {% else %}
                    <li class="page-item disabled">
                        <span class="page-link"><i class="bi bi-chevron-double-right"></i></span>
                    </li>
                {% endif %}
            </ul>
        </div>
    </div>
</nav>
{% endif %}